<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="java.util.Locale"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<base href="<%=basePath%>"/>
<html>
<head>

<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>treelistdemo</title>
<link href="platform/skins/skin01/css/commonbg.css" rel="stylesheet" />
  	
    <link href="../skins/skin01/css/easyuicombo.css" rel="stylesheet" />
    <link href="platform/skins/skin01/css/treeView.css" rel="stylesheet" />
    
    <link href="../skins/skin01/css/customtabs.css" rel="stylesheet" />
    
    <!-- 
    <link href="../skins/skin01/css/easyuiwindow.css" rel="stylesheet" />
    -->
    
    <link href="platform/skins/skin01/css/zyicons.css" rel="stylesheet" />
    <link href="platform/skins/skin01/css/list.css" rel="stylesheet" id="searchpagecss" />
    
    <!-- for form -->
    <link href="../skins/skin01/css/ucheckbutton.css" rel="stylesheet" />
	<link href="../skins/skin01/css/form.css" rel="stylesheet" />	
	<script src="platform/js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
	<script src="../js/list.js" type="text/javascript"></script>
	<script type='text/javascript' src='platform/supreport/binary/dynaload.js?48'></script>
    <script src="js/mootools.v1.11.js" type="text/javascript"></script>
    <script src="js/WebService.js" type="text/javascript"></script>
<script language="JavaScript"> 
	var        btype="";
	function getOs()  
	{  
	   var OsObject = "";  
	   if(navigator.userAgent.indexOf("MSIE")>0) {  
	                return "MSIE";       //IE浏览器
	   }
	   if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){  
	                return "Firefox";     //Firefox浏览器
	   }
	   if(isSafari=navigator.userAgent.indexOf("Safari")>0) {  
	                return "Safari";      //Safan浏览器
	   }
	   if(isCamino=navigator.userAgent.indexOf("Camino")>0){  
	                return "Camino";   //Camino浏览器
	   }
	   if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){  
	                return "Gecko";    //Gecko浏览器
	   }  
	} 


	 function OnReady(id)
	 {
	  AF.func("Build", "platform/supreport/tree/demotree.xml");
	  focusIE(AF);
	 }
	 function getChangedXML()
	 {
	  focusIE(AF);
	 }
 
	 function doRequestUsingGET()
	{
		  createXMLHttpRequest();
		  btype=getOs();
		  var queryString="servlet/getProduct?timeStamp=" + new Date().getTime();
		  if(queryString==null||queryString=='') return;
		  if(queryString!="0"){
		   xmlHttp.onreadystatechange = (btype!="Firefox")?(requestStateChange) : (requestStateChange());
		   xmlHttp.open("GET",queryString,false);
		   xmlHttp.send(null);
		   xmlHttp.onreadystatechange = (btype!="Firefox")?(requestStateChange) : (requestStateChange());
		  }
	}
	var service ;
	function doRequestUsingWebservice(){
	   btype=getOs();
	   var url = "services/IProductService";
	        var op = {
	              onComplete:showResponse,
	              onFailure:showError,
	              update:''
	            };
	        service = new WebService(url,"getProducts",op);
	        service.request();
	        return false;
	}

    function showError(obj)
    {
		alert("error");
    }
    
    function showResponse(requestText,requestXML)
    {
    	AF.func("Load",requestXML.text);
	    focusIE(AF);
    }
	function doRequestUsingPost()
	{
		 btype=getOs();
		  try{
			 createXMLHttpRequest();
			 var url="servlet?timeStamp=" + new Date().getTime();
			 var queryString=AF.func("GetChangedXML", "0");
			 if(queryString==null||queryString=='') return;
			 if(queryString!="0"){
			  xmlHttp.open("POST",url,false);
			  xmlHttp.onreadystatechange = (btype!="Firefox")?(handleStateChange) : (handleStateChange());
			  xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			  xmlHttp.send(queryString);
			  xmlHttp.onreadystatechange = (btype!="Firefox")?(handleStateChange) : (handleStateChange());
			 }
		  }catch(e){
			 alert(e.name + " : " + e.message); 
		 }
	}

	function doRequestModifyUsingPost(level)
	{
		 btype=getOs();
		 try{
			  createXMLHttpRequest();
			 var url="servlet?timeStamp=" + new Date().getTime();
			 var queryString=AF.func("GetChangedXML", level);
			 if(queryString==null||queryString=='') return;
			 if(queryString!="0"){
			    xmlHttp.open("POST",url,false);
			    xmlHttp.onreadystatechange = (btype!="Firefox")?(handleStateChange) : (handleStateChange());
			    xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
			    xmlHttp.send(queryString);
			    xmlHttp.onreadystatechange = (btype!="Firefox")?(handleStateChange) : (handleStateChange());
			  }
		 }catch(e){
			 alert(e.name + " : " + e.message); 
		 }
	}
	
	function requestStateChange()
	{
	 btype=getOs();
	 if(xmlHttp.readyState==4||btype=="Firefox")
	 {
	  if(xmlHttp.status==200)
	  {
		alert(xmlHttp. responseText);
	  	AF.func("Load",xmlHttp.responseText);
	    focusIE(AF);
	  }
	 }
	}

	var xmlHttp;
	function createXMLHttpRequest()
	{
		     xmlHttp = false;
        //开始初始化XMLHttpRequest 对象
        if(window.XMLHttpRequest) { //Mozilla 浏览器
              xmlHttp = new XMLHttpRequest();
              if (xmlHttp.overrideMimeType) {//设置MiME 类别        
                  xmlHttp.overrideMimeType("text/xml");
                 }
        }else if (window.ActiveXObject) { // IE 浏览器
                        try {
                        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
                        } catch (e) {
                             try {
                              xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                            } catch (e) {}
                        }
        }
        if (!xmlHttp) { // 异常，创建对象实例失败
                        window.alert("不能创建XMLHttpRequest 对象实例.");
                        return false;
        }
        return xmlHttp;
	}

	function handleStateChange()
	{
	  btype=getOs();
	 if(xmlHttp.readyState==4||btype=="Firefox")
	 {
	  if(xmlHttp.status==200)
	  {
	  	alert(xmlHttp.responseText);
	    focusIE(AF);
	  }
	 }
	}

	function retrieve()
	{
	  AF.func("Load", 'index2.vm?template=index2.vm');
	  focusIE(AF);
	}
	 
	function addItem(){
	 AF.func("InsertRows","-1");
	}
	
	function deleteCurrentItem(){
	AF.func("DeleteCurrentRow","");
	}
</script>
</head>
<body style="margin:0">

<div id="datatabdiv">
           <div class="panelHeader">
              <a href="javascript:doNewRow()" class="btnicon">
	            <span class="btnicon-left">
	                <span class="zyicons add"></span>
	                <span class="btntxt">新增</span>
	            </span>
		       </a>
		       <a href="javascript:doSave()" class="btnicon">
		            <span class="btnicon-left">
		                <span class="zyicons pencil"></span>
		                <span class="btntxt">编辑</span>
		            </span>
		       </a>
		       
		       <a href="javascript:doNewRow()" class="btnicon">
	            <span class="btnicon-left">
	                <span class="zyicons edit"></span>
	                <span class="btntxt">编辑2</span>
	            </span>
		       </a>
		       
		       <a href="javascript:doSave()" class="btnicon">
		            <span class="btnicon-left">
		                <span class="zyicons remove"></span>
		                <span class="btntxt">删除</span>
		            </span>
		       </a>
		       <a href="javascript:doSave()" class="btnicon">
		            <span class="btnicon-left">
		                <span class="zyicons del"></span>
		                <span class="btntxt">删除2</span>
		            </span>
		       </a>
		      
		       <a href="javascript:doSave()" class="btnicon">
		            <span class="btnicon-left">
		                <span class="zyicons search"></span>
		                <span class="btntxt">查询</span>
		            </span>
		       </a>
		       <a href="javascript:doSave()" class="btnicon">
		            <span class="btnicon-left">
		                <span class="zyicons download"></span>
		                <span class="btntxt">导出</span>
		            </span>
		       </a>
		       <a href="javascript:doSave()" class="btnicon">
		            <span class="btnicon-left">
		                <span class="zyicons download"></span>
		                <span class="btntxt">导入</span>
		            </span>
		       </a>
		       <a href="javascript:doSave()" class="btnicon">
		            <span class="btnicon-left">
		                <span class="zyicons col"></span>
		                <span class="btntxt">设置</span>
		            </span>
		       </a>
		       
		       <a href="javascript:doSave()" class="btnicon">
		            <span class="btnicon-left">
		                <span class="zyicons no"></span>
		                <span class="btntxt">取消</span>
		            </span>
		       </a>
		        <a href="javascript:doSave()" class="btnicon">
		            <span class="btnicon-left">
		                <span class="zyicons ok"></span>
		                <span class="btntxt">确认</span>
		            </span>
		       </a>
		      
		       <a href="javascript:doSave()" class="btnicon">
		            <span class="btnicon-left">
		                <span class="zyicons print"></span>
		                <span class="btntxt">打印</span>
		            </span>
		       </a>
		       
		       
		       <a href="javascript:doSave()" class="btnicon">
		            <span class="btnicon-left">
		                <span class="zyicons save"></span>
		                <span class="btntxt">保存</span>
		            </span>
		       </a>
		       
		       &nbsp;
            </div>
               <!--
               <div class="searchheader">查询</div>
               
               <form name="qName" id="qName" method="post" > 
                -->
                <!-- 
                <div id="tabsearchheader" class="clearfloat" >
                    <span>组织架构</span>
                    <select class="myeasyui-combobox" name="searchselect1" style="width: 100px;">
                        <option value="0">0</option>
                        <option value="1">1</option>
                        <option value="2">2</option>
                    </select>
                    <span class="title">组织架构</span>
                    <input type="text" id="txttabsearch1" class="inputtxt" />
                    
                    <span class="title">时间条件</span>
                    <span class="tabheadertimespan">
                        <input type="text" id="txttabsearch2" class="txttabtime" readonly="readonly" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'txttabsearch3\')||\'2020-10-01 00:00:00\'}',dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
                        <span class="ui-datepicker-trigger"></span>
                    </span>
                    <label class="totimelabel">--</label>
                    <span class="tabheadertimespan">
                        <input type="text" id="txttabsearch3" class="txttabtime" readonly="readonly" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'txttabsearch2\')}',maxDate:'2020-10-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss'})" />
                        <span class="ui-datepicker-trigger"></span>
                    </span>
                    <a id="btnsearch" class="btnicon" onclick="doSearch()">
                        <span class="btnicon-left">
                            <span class="zyicons search"></span>
                            <span class="btntxt">搜索</span>
                        </span>
                    </a>
                    <span id="btngjsearch">高级搜索</span>
                </div>               
                -->
               <!--  </form>  -->
                
</div>


<div style="position:relative;width:100%;height:290px">
	<script>
	insertTreeList('AF', '');	
	//insertReport('AF', 'PagesTabPercent=50');
	
	</script>
</div>
<br/>
<div align="right" style="position:relative;width:100%;align:right">
	<input type=button value="增行" onClick="addItem()">
	<input type=button value="删行" onClick="deleteCurrentItem()">
</div>
<center>
<div style="position:relative;width:100%;align:left">
	获取数据:
	<input type=button value="取数-Velocity" onClick="retrieve()">
	<input type=button value="取数-Servlet" onClick="doRequestUsingGET()">
	<input type=button value="取数-WebService" onClick="doRequestUsingWebservice()">
	提交数据：
	<input type=button value="提交-Level0" onClick="doRequestUsingPost()">
	<input type=button value="提交-Level1" onClick="doRequestModifyUsingPost(1)">
	<input type=button value="提交-Level2" onClick="doRequestModifyUsingPost(2)">
</div>
</center>
</body>

</html>
